package com.jet.chat.command;

import java.util.regex.Matcher;

import com.jet.chat.dbquery.ChatQueryReadConfirmation;
import com.jet.chat.dbquery.ChatQueryReadConfirmationParams;
import com.jet.chat.message.Message;
import com.jet.chat.server.ChatServer;
import com.jet.chat.server.ChatSession;

public class ChatCommandReadConfirmation extends ChatCommandAbstract {

	public ChatCommandReadConfirmation() {
		super("^/\\w+\\s(\\d+)$");
	}

	@Override
	protected void executeCommand(Matcher matcher, ChatServer chatServer, ChatSession chatSession, Message chatMessage) throws Exception {
		int messageId = Integer.parseInt(matcher.group(1));
		new ChatQueryReadConfirmation().execute(chatServer.getDBConnectionService(), new ChatQueryReadConfirmationParams(messageId, chatSession.getUserId()));
	}

}
